﻿using System;
using System.Configuration;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.Collections.Generic;
using System.Text;
using System.Web;

namespace BPM
{
    [ServiceContract(Namespace = "")]
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class ServerSettings
    {
        [OperationContract]
        public string GetSetting(string key)
        {
            return ConfigurationManager.AppSettings.Get(key);
        }

        [OperationContract]
        public Dictionary<string,string> GetSettings(List<string> keys)
        {
            Dictionary<string,string> settings=new Dictionary<string, string>();
            foreach(string key in keys)
            {
                settings.Add(key, ConfigurationManager.AppSettings.Get(key));
            }
            return settings;
        }

        [OperationContract]
        public Dictionary<string, string> GetAllSettings()
        {
            Dictionary<string, string> settings = new Dictionary<string, string>();
            foreach(string key in ConfigurationManager.AppSettings.AllKeys)
            {
                settings.Add(key, ConfigurationManager.AppSettings.Get(key));
            }
            return settings;
        }

        [OperationContract]
        public string GetClientIdentity()
        {
            return HttpContext.Current.User.Identity.Name;
        }
    }
}
